package com.proton.carepatchtemp.fragment.dialogfragment;

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.proton.carepatchtemp.R;
import com.proton.carepatchtemp.constant.Config;
import com.proton.carepatchtemp.constant.Extras;
import com.proton.carepatchtemp.utils.SpUtils;


public class TestNoticeFragment extends DialogFragment implements View.OnClickListener {
    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;
    private View view;
    /**
     * 我知道了
     */
    private Button mBtNoticeExit;
    private TextView mTvNotice;

    public TestNoticeFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @param param2 Parameter 2.
     * @return A new instance of fragment TestNoticeFragment.
     */
    // TODO: Rename and change types and number of parameters
    public static TestNoticeFragment newInstance(String param1, String param2) {
        TestNoticeFragment fragment = new TestNoticeFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        View view = inflater.inflate(R.layout.fragment_test_notice, container, false);
        // Inflate the layout for this fragment
        initView(view);
        setListener();

        if (1 == SpUtils.getInt(Extras.TEMP_UNIT, Config.TEMP_UNIT_DEFAULT)) {

        } else {
            mTvNotice.setText(R.string.real_time_test_notice_f);
        }

        return view;
    }

    private void setListener() {
        mBtNoticeExit.setOnClickListener(v -> {
            TestNoticeFragment.this.dismissAllowingStateLoss();
        });
    }

    private void initView(View view) {
        mBtNoticeExit = view.findViewById(R.id.bt_notice_exit);
        mBtNoticeExit.setOnClickListener(this);
        mTvNotice = view.findViewById(R.id.tv_notice);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bt_notice_exit:
                break;
        }
    }
}
